<template>
	<view>
		<view class="" style="width: 100%;height: 500rpx;">
						<map :markers="markers" scale='18' :enable-satellite='checkedWeixin'  enable-building='true' 
						 style="width: 100%; height:500rpx;" :latitude="latitude" :longitude="longitude"
							id="map" ref='map' >
						</map>
					</view>
		<view class="businessInfoList" v-for="item in BusinessInfoList" @tap="changeBusiness(item)">
			<view class="image"><image :src="item.jsonViewData.businessLogo" mode="widthFix"></image></view>
			<view class="name">
				<view class="name-one">{{ item.jsonViewData.businessName }}</view>
				<view class="name-two">{{ item.jsonViewData.businessAddress.address }}</view>
			</view>
			<view class="">
					   <radio :checked="item.checked"  />
			</view>
		</view>
	</view>
</template>

<script>
import { getBusinessInfoList, getRecommen, getHomeDataInfo, getCategory } from '../../../utils/api.js';
export default {
	data() {
		return {
			BusinessInfoList: [],
			nowBusinessInfo:{},
			checkedWeixin:false,
							latitude:uni.getStorageSync('nowBusinessInfo').jsonViewData.businessAddress.latitude ,
							longitude:uni.getStorageSync('nowBusinessInfo').jsonViewData.businessAddress.longitude ,
							markers: [{
								id: 0,
								title: uni.getStorageSync('nowBusinessInfo').jsonViewData.businessName,
								width: 40,
								height: 40,
								iconPath:uni.getStorageSync('nowBusinessInfo').jsonViewData.businessLogo,
								latitude:uni.getStorageSync('nowBusinessInfo').jsonViewData.businessAddress.latitude ,
								longitude:uni.getStorageSync('nowBusinessInfo').jsonViewData.businessAddress.longitude ,
							}]
		};
	},
	onShow() {
		this.nowBusinessInfo=uni.getStorageSync('nowBusinessInfo')
		this.getBusinessInfoList();
		
	},
	methods: {
		getBusinessInfoList() {
			getBusinessInfoList().then(res => {
				if (res.code == 200) {
					this.BusinessInfoList = res.body;
					this.BusinessInfoList.forEach(item => {
						if(item.jsonViewData.businessId==this.nowBusinessInfo.jsonViewData.businessId){
							item.checked=true
						}
					});
						
				
				}
			});
		},
		changeBusiness(item){
			uni.setStorage({
				key: 'nowBusinessInfo',
				data: item
			});
			uni.navigateBack({delta:1})
		}
	}
};
</script>

<style scoped lang="scss">

.businessInfoList {
	padding: 20rpx;
	display: flex;
	align-items: center;
	justify-content: space-between;
	border-bottom: 1rpx solid #f5f5f5;
	image {
		width: 100rpx;
		height: 100rpx;
		border-radius: 50rpx;
	}
	.name {
		width: 500rpx;
		.name-one {
			font-size: 28rpx;
			font-weight: 700;
		}
		.name-two {
			width: 500rpx;
			white-space: nowrap; 
			text-overflow:ellipsis; 
			overflow:hidden;
			font-size: 26rpx;
			color: #999;
			padding-top: 20rpx;
			
		}
	}
}
</style>
